layui.use(['form','layer','table','laytpl'],function(){
    var form = layui.form,
        layer = parent.layer === undefined ? layui.layer : top.layer,
        $ = layui.jquery,
        laytpl = layui.laytpl,
        table = layui.table;

    //检验类型列表
    var tableIns6 = table.render({
        elem: '#Schild',
        url : '../../../json/userList.json',
        cellMinWidth : 95,
        page : true,
        height : "full-125",
        limits : [10,15,20,25],
        limit : 20,
        id : "SchildTable",
        cols : [[
            {type: "checkbox", fixed:"left", width:50},
            {field: "ID",title: "ID",align: 'center'},
            {field: 'testType',title: '检验类型',align: 'center'},
            {
                field: 'testClassify', title: '检验分类', align: 'center', templet: function (d) {
                    if (d.testClassify == "0") {
                        return "质量";
                    } else if (d.testClassify == "1") {
                        return "安全";
                    }
                }
            },
            {field: 'Sname', title: '标准名称', minWidth:100, align:"center"},
            {field: 'SContent',title: '标准内容', align:'center',width: 200,},
            {field: 'version',title: '版本号',align: 'center'},
            {field: 'status',title: '状态',align: 'center'},
            {title: '操作', minWidth:175, templet:'#userListBar',fixed:"right",align:"center"},

        ]]
    });

    //搜索【此功能需要后台配合，所以暂时没有动态效果演示】
    $(".search_btn").click(function () {
        var inputVal = $('.layui-input ').val();

        table.reload('userListTable', {

            url: '../../../json/userList.json',
            method: 'post',
            request: {
                statusName: 'status',
            },
            where: {
                inspectTypeID: inputVal,
                status: 0

            },
            page: {
                curr: 1
            }

        })
    })


    //列表操作
    table.on('tool(userList)', function(obj){
        var data = obj.data;

        if(obj.event === 'usable'){ //是否启用
            var _this = $(this),
                usableText = "是否确定禁用此用户？",
                btnText = "已禁用";
            if(this.text()=="已禁用"){
                usableText = "是否确定启用此用户？",
                    btnText = "已启用";
            }
            layer.confirm(usableText,{
                icon: 3,
                title:'系统提示',
                cancel : function(index){
                    layer.close(index);
                }
            },function(index){
                _this.text(btnText);
                layer.close(index);
            },function(index){
                layer.close(index);
            });
        }

    });

})